from logging import getLogger

from zope.interface import Interface
from zope.configuration import fields
from zope.schema import TextLine



log = getLogger('meercat.base.zcml')

class IRegistryItemSchema(Interface):
    name = TextLine(
        title=u'Name',
        description=u'A name unique within the context',
        required=True)
    
    component = fields.GlobalObject(
        title=u'Component',
        description=u'A unique component within the context',
        required=False)
    
    before = TextLine(
        title=u'Before',
        description=u'The name of another item to insert before',
        required=False,
        default=None)
    
    after = TextLine(
        title=u'After',
        description=u'The name of another item to insert before',
        required=False,
        default=None)
    
    first = fields.Bool(
        title=u'First',
        description=u'Set to true to insert before all other items',
        required=False,
        default=None)
    
    last = fields.Bool(
        title=u'Last',
        description=u'Set to true to insert after all other items',
        required=False,
        default=None)
    
    remove= fields.Bool(
        title=u'Remove',
        description=u'Remove this item from the list of items',
        required=False,
        default=False)

def registrationHandler(context, name, **kwargs):
    return context.register(name, **kwargs)
